package com.lzb.auth.service;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Service;

import com.lzb.auth.domain.MngRole;
import com.lzb.auth.mapper.MngRoleMapper;
import com.lzb.mngUser.Pagination;

@Service(MngRoleService.BEAN_PACKAGE_NAME)
public class MngRoleService {

	@Resource(name = "sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	
	public static final String BEAN_PACKAGE_NAME = "com.lzb.auth.service.MngRoleService";
	
	public void add(MngRole role) {
		try {
			sqlSessionTemplate.getMapper(MngRoleMapper.class).insert(role);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	public List<MngRole> getMngRoleByPagination(Pagination<MngRole> pagination) {
		try {
			return sqlSessionTemplate.getMapper(MngRoleMapper.class).selectByPagination(pagination);
		} catch(Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public void updateByID(MngRole mngRole) {
		try {
			sqlSessionTemplate.getMapper(MngRoleMapper.class).updateByPrimaryKeySelective(mngRole);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}
